package org.news.web.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.news.web.domain.News;
import org.news.web.domain.vo.NewsVo;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;

import java.util.List;
import java.util.Set;

/**
 * 新闻功能Mapper接口
 *
 * @author Gu Ci
 * @date 2024-04-03
 */
public interface NewsMapper extends BaseMapperPlus<News, NewsVo> {

    @Select("SELECT * FROM news WHERE news_id IN (${ids}) ORDER BY FIELD(news_id, ${ids})")
    List<NewsVo> getHotRankIng(@Param("ids")String hotRanking);


    @Select("SELECT sum(views) FROM `news` where author_type=2 and author=${id};")
    Long AuthorAllViewCount(@Param("id")Long id);


    @Select("SELECT sum(comments) FROM `news` where author_type=2 and author=${id};")
    Long AuthorAllCommCount(@Param("id")Long id);

}
